package org.grow.jpago.service;

import org.grow.jpago.dao.StudentScoreDao;
import org.grow.jpago.entity.StudentScore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;

/**
 * @Author: xwg
 * @CreateDate: 21-7-14
 */

@Service
public class DealBillService {

    @Autowired
    private StudentScoreDao studentScoreDao;

    @Transactional
    public Boolean txDeal(StudentScore supplier,StudentScore consumer,Integer dealScore){
        supplier.setOnlineScore(supplier.getOnlineScore()-dealScore);
        studentScoreDao.save(supplier);

        consumer.setOnlineScore(consumer.getOnlineScore()+dealScore);
        studentScoreDao.save(consumer);
        return true;
    }
}
